<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	template="/WEB-INF/template.xhtml">
	<ui:define name="title">Privileges</ui:define>
	<ui:define name="body">
		<h:form id="mainForm">
			<p:dataTable id="table" var="row" value="#{hsmProxyPrivileges.list}"
				rows="15" paginator="true" resizableColumns="true">
				<p:column>
					<f:facet name="header">Card Number</f:facet>
					<h:outputText value="#{row.cardNumber}" />
				</p:column>
				<p:column>
					<f:facet name="header">Pending</f:facet>
					<h:outputText value="#{row.pending}" />
				</p:column>
				<p:column>
					<f:facet name="header">Actions</f:facet>

					<p:commandLink id="approveButton"
						styleClass="ui-icon ui-icon-check" style="display:inline-block;"
						actionListener="#{hsmProxyPrivileges.approveAdministrator}"
						update=":messages,:mainForm" rendered="#{row.pending}">
						<f:attribute name="selectedAdministrator" value="#{row}" />
					</p:commandLink>
					<p:tooltip for="approveButton" value="Approve administrator..." />

					<p:commandLink id="removeButton" styleClass="ui-icon ui-icon-trash"
						style="display:inline-block;"
						actionListener="#{hsmProxyPrivileges.selectAdministrator}"
						oncomplete="removeDialog.show();" update=":messages,:removeForm">
						<f:attribute name="selectedAdministrator" value="#{row}" />
					</p:commandLink>
					<p:tooltip for="removeButton" value="Remove administrator..." />
				</p:column>
			</p:dataTable>
		</h:form>

		<p:confirmDialog header="Remove Administrator"
			message="Are you sure to remove the administrator?" severity="alert"
			widgetVar="removeDialog">
			<h:form id="removeForm">
				<p:commandButton id="removeButton" value="Yes"
					actionListener="#{hsmProxyPrivileges.removeSelectedAdministrator}"
					oncomplete="removeDialog.hide()" update=":mainForm,:messages" />
				<p:commandButton value="No" onclick="removeDialog.hide();" />
			</h:form>
		</p:confirmDialog>

	</ui:define>
</ui:composition>